package com.practice.string;

public class RemoveDuplicates {
	public String remove(String string) {
		if (string==null || string.length()<2) return string;
		
		boolean[] hit = new boolean[256];
		char[] c = string.toCharArray();
		
		int tail = 0;
		hit[c[tail]] = true;
		
		for (int i=1; i<c.length; i++) {
			if (!hit[c[i]]) {
				tail++;
				c[tail] = c[i];
				hit[c[i]] = true;
			}
		}
		
		return new String(c, 0, tail+1);
	}
}
